package com.yupi.springbootinit.config;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.yupi.springbootinit.constant.RedisConstant;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * @author admin
 * @date 2025/4/25
 */
@Configuration
public class CaffeineConfig {

    @Bean
    public Cache<String, String> localCache() {
        return Caffeine.newBuilder()
                .initialCapacity(1000)
                .maximumSize(10_000)
                .expireAfterWrite(RedisConstant.THIRTY_TTL, TimeUnit.MINUTES)
                .build();
    }
}
